<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>


<body>
    <div>
        <h1 class="c1"></h1>
    </div>
 <script type="text/javascript">
    window.addEventListener('load',function(e){
        if(!navigator.onLine){
           console.log('网络异常！')
        }
    })
     window.addEventListener('offline',function(e){
         console.log('网络关闭!');
     });
     window.addEventListener('online',function(e){
         console.log('网络开启!');
     });
 </script>
</body>

</html>